//
//  LWFeedBackCtrl.m
//  laowu
//
//  Created by 曹秀云 on 15/5/1.
//  Copyright (c) 2015年 长沙市岳麓区立早网络科技有限公司. All rights reserved.
//

#import "LWFeedBackCtrl.h"

@interface LWFeedBackCtrl ()<UITextViewDelegate>

@end

@implementation LWFeedBackCtrl

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setTitle:@"意见反馈"];
    [self.texttView setCornerRadius:0 borderWidth:1 borderColor:HEXColor(@"#dfdfdf")];
    [self.texttView setDelegate:self];
    [self.feedBackBtn addTarget:self action:@selector(feedBackBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    // Do any additional setup after loading the view from its nib.
}

-(void)feedBackBtnClick:(UIButton *)btn{
    if (ISBLANK(self.texttView.text)) {
        [DialogUtils showTipsWithView:nil String:@"反馈内容为空！"];
        return;
    }
  
    if ([self.texttView.text length] < 5 || [self.texttView.text length] > 500){
        [DialogUtils showTipsWithView:nil String:@"反馈内容字数不正确"];
        return;
    }
    
    [MeDataTool feedBackWithContent:self.texttView.text success:^(BaseResponse *result) {
        if (result.isSucc) {
            
            [DialogUtils showTipsWithView:nil String:@"提交成功"];
            [self.navigationController popViewControllerAnimated:YES];
        }else{
            [DialogUtils showTipsWithView:nil String:result.msg];
        }
    } failure:^(NSError *error) {
        [DialogUtils showTipsWithView:nil String:@"反馈失败！"];
    }];
}

//TextView Delegate
- (void) textViewDidChange:(UITextView *)textView{
    if ([self.texttView.text length] == 0) {
        [self.defaultInfoLabel setHidden:NO];
    }else{
        [self.defaultInfoLabel  setHidden:YES];
    }
}


@end
